<?php header("Content-type: text/css"); ?>
<?php

function perfect_color($hexcolor, $dark = '#222', $light = '#FFF')
{
	$color = explode("#",$hexcolor);
    return (hexdec($color[0]) > 0xffffff/2) ? $dark : $light;
}

$c = explode(",",$_GET['c']);

$body_bg_color = '#'.$c[0]; //background color

$hd_ft_bg_color = '#'.$c[1]; //background color inside header/footer

$secondary_color = '#'.$c[2]; //text color inside header/footer

$bd_bg_color = '#'.$c[3];

$a_link_color = '#'.$c[4];

$a_hover_color = '#'.$c[5];

$hd_ft_bg_image = false;

$round = false;

$threshold = "#999999";
$dark = "#222";
$light = "#fff";

//calculated
//$date_bg_color = ($body_bg_color == "#FFF" || $body_bg_color == "#fff" || $body_bg_color == "#ffffff" || $body_bg_color == "#FFFFFF") ? "#444":$hd_ft_bg_color;
$date_bg_color = $hd_ft_bg_color;

?>
html,body { background-color: <?php echo $body_bg_color; ?>; margin:0; padding:0 }

/* BACKGROUND COLOR IN HEADER AND FOOTER */
#hd,#ft { 
	background-color: <?php echo $hd_ft_bg_color;?>; 
    <?php if($hd_ft_bg_image) : ?>
	background-image: url(http://zurb.com/images/alert-overlay.png); 
    background-position: top;
    background-repeat: repeat-x;
    <?php endif; ?>
    <?php //if round corners
	if($round) : ?>
   	-moz-border-radius:0.5em;
	-webkit-border-radius:0.5em;
	border-radius: 0.5em;
    <?php endif; ?>
    
}

/* TEXT COLOR IN HEADER AND FOOTER */
#ft,#hd { color:#fff; }


/* BACKGROUND COLOR IN CONTENT */
#content {
	background-color: <?php echo $bd_bg_color; ?>;    
    <?php 
	//if round corners
	if($round) : 
	?>
   	-moz-border-radius:0.5em;
	-webkit-border-radius:0.5em;
	border-radius: 0.5em;
    <?php endif; ?>
}

/* WIDGET */
h3.widgettitle {  color:<?php echo perfect_color($secondary_color); ?>; background-color: <?php echo $secondary_color; ?>; <?php if($hd_ft_bg_image) : ?>
	background-image: url(http://zurb.com/images/alert-overlay.png); 
    background-position: top;
    background-repeat: repeat-x;
    <?php endif; ?>
}

/* LINK COLOR */
a:focus, 
a:hover     { color: <?php echo $a_hover_color; ?>; border:0 }
a	{ color: <?php echo $a_link_color; ?>; text-decoration:none; border-bottom:1px dotted #444; }

/* DATE BG COLOR */
.date { background-color: <?php echo $date_bg_color ; ?>; color: <?php echo perfect_color($date_bg_color); ?> }

/* NAVIGATION COLORS */
.navigation a:hover { background-color: <?php echo $secondary_color; ?>; color: <?php echo perfect_color($secondary_color); ?>; }

/*SIDEBAR TOP AND BOTTOM */
#sidebartop,#sidebarbottom { 
	clear:both;
	padding:1em;
    margin:1em 0;
	background-color:#fff;
   	-moz-border-radius:0.5em;
	-webkit-border-radius:0.5em;
	border-radius: 0.5em;
}